home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / toolkit / vbof_v11 / vbofomgr.cls < prev    next >
Text File  |  1996-03-03  |  80KB  |  2,550 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "VBOFObjectManager"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. ' VB Object Framework
  11. '   Version 1.0a
  12. '
  13. ' (c) Copyright 1995 Ken Fitzpatrick
  14. '     All Rights Reserved
  15. '     Cannot be distributed or sold without permission
  16. '
  17. ' Please refer to the attached User's Guide in file
  18. '   "VBOF.doc" for important infomation.
  19. '   Microsoft Word v.6.0 (or later) or equivalent
  20. '   viewer is required.
  21. '
  22. ' The VB Object Framework and this demonstration
  23. '   package are provided on an as-is,
  24. '   use-at-your-own-risk basis.
  25. ' Even though thorough testing has been performed
  26. '   on this product and demonstration package and
  27. '   every resonable precaution has been taken, the
  28. '   author assumes no responsibilities of any
  29. '   actions or damages which result from the use of
  30. '   this product or demonstration package.
  31. ' The above statement is necessary because the very
  32. '   nature of VB Object Framework is to manipulate
  33. '   data in the form of objects.  Under certain
  34. '   circumstances, particularly under situations of
  35. '   misuse or where the user is unfamiliar the
  36. '   product, it would be possible to damage or
  37. '   destroy data.  The author cannot, and will not,
  38. '   be responsible for such use of this product or
  39. '   demonstration package.
  40. '
  41. ' To-Do:
  42. '   Coll.Sort: try direct manipulation of
  43. '       object ordering (versus .Remove, .Add)
  44. '   Wrappers.Sort: Sort, then Refresh DisplayOnly:=True
  45. '   DataWrapper: support Validate event
  46. '   Collection.Hide
  47. '   New...Wrapper(Parent:=),
  48. '       TerminateForm
  49. '           delete all Coll where Parent=Form
  50. '   CollectionArray
  51. '   test auto-regist Wrapper, terminate Wrapper
  52. '
  53. ' Errors:
  54. '
  55. ' Done:
  56. '   Sort
  57. '   Test .Add After:=AnObject
  58. '   Split lines at each parameter of Public methods
  59. '   (ListBoxWrapper.AddItems) Clear:= to pre-Clear
  60. '       the ListBox
  61. '   Availability of an Object:= parameter at every
  62. '       public method where an Item:= parameter is
  63. '       available
  64. '   1.0a
  65. '   Get/Let Properties for AbsolutePosition
  66. '   Full test with errors enabled
  67. '   Identify the Class Module Name which "does not
  68. '       understand" (e.g. "ObjectNewObjectOfMyClass",
  69. '       etc.) in error mesages
  70. '   Not Done (avoiding .Rebind due to invalid state
  71. '       is not informational to the user):
  72. '       Move readiness code from NewVBOF...Wrapper
  73. '           to Wrapper.Rebind
  74. '   Coll: remove need for ObjectLink.CLS
  75. '   Method Form_QueryUnload (Form, Wrappers())
  76. '   RecordSetWrapper: as a subset of the
  77. '       DataWrapper
  78. '   confirm all RegisteredEventObjects are
  79. '       cleaned-up
  80. '   check Object.ObjectDataSource before
  81. '       actually going to the database in
  82. '       OMgr.NewObject
  83. '   Addresses are missing their States, Persons
  84. '       are missing their Mothers and Fathers
  85. '   DBGrid support (remaining Unbound functions)
  86. '   use ListBoxWrappers in DBGrid example
  87. '       (for States, Genders, MaritalStatus)
  88. '   ListBoxWrapper.Rebind
  89. '   OMgr.NewListBoxWrapper: use newLBWrapper.Rebind
  90. '   Clinton's are missing their Address
  91. '   non-Access-specific SQL
  92. '   Add "Set Chelsea.Mother = Hillary" and
  93. '       "Set Chelsea.Father = Bill" to
  94. '       CreateTestData
  95. '   Add "Set Address.State = States.Item(x)" to
  96. '       CreateTestData
  97. '   PopulateCollection
  98. '       RecordSet:=, DB:=,
  99. '       invokes InstantiateFromDB or InstnatiateFromRS
  100. '   NewObject
  101. '       DB:=, SampleObject:=, SQL:=, ObjectID:=,
  102. '       ODBCPassThru:=, NullIfNotFound:=T|F,
  103. '       ANSISQL:=T|F
  104. '   elimiate ListBox:= from Property Get & Sets
  105. '       to be able to remove corresp parm from
  106. '       application calls to Wrapper
  107. '   don't Coll.DetachFromLBWrapper ... would disable
  108. '       support for 1:many (Coll:Wrappers)
  109. '       Figure another way to free the prev Wrapper
  110. '   function to return an instantiated object, given
  111. '       TypeName & ID
  112. '   single copy of StateCodes, MaritalStatus, etc.
  113. '   support Meth=SystemObject(TypeName:=, ObjectID:=)
  114. '   incorp code currently required in methods such
  115. '       as "Persons", "Addresses", etc.
  116. '       (Meth=ManageCollection)
  117. '   Support ODBC Pass Thru
  118. '   Elim redundant "With pvtCurrentPerson : .Name = efName"
  119. '       in demo forms
  120. '   Speed performance by checking for Key=(TypeName)&" "&ObjectID
  121. '       before scanning full SystemObjects
  122. '   (Error) .Replace not deleting link to previous item
  123. '   (Error) .RemoveCollection removes objects prematurely
  124. '       (try the 2 nonDataControl windows, close
  125. '       one, then go after the objects from the other)
  126. '   (Error) Coll.Remove deletes the parent linkage, but
  127. '       that should be persistent
  128. '   added ANSI SQL support (optional)
  129. '   enhanced RecordSet wrapper capability with
  130. '       MoveFirst, MoveLast, FindFirst, FindLast,
  131. '       FindNext, FindPrevious, BOF, EOF
  132. '   CollectionIndex(Where:=FindString)
  133. '   Use-at-your-own-risk message (.txt, in Intro.FRM)
  134. '   propagate code on ListBoxDemo.RefreshCustomerList
  135. '       for dealing with a removed object which had
  136. '       previously been the "pvtCurrent" object
  137. '   Test pvtParentsOfObject()
  138. '   Set (all) tempObject = Nothing
  139. '   Incorp State, MaritalStatus, Gender objects into
  140. '       GUI examples
  141. '   Hold position of CurrentObject in DataControl
  142. '       example
  143. '   Hold position of CurrentObject in DataControl
  144. '       example
  145. '   need to remove item from collection before
  146. '       .TriggerObjectEvent Event=RemovedItem
  147. '       (Trigger between Collections)
  148. '   Finish ListBox example: "Add", "Upd", "Del"
  149. '   Remove references to each object's own EventManager
  150. '   send "Added" trigger to objects which are
  151. '       newly added to the collection
  152. '   send "Instantiated" trigger to objects which
  153. '       are newly instantiated
  154. '   Rename to VBOF for smaller space consumption
  155. '       in the VB Object Browser
  156. '   Support EventManager interface in ObjectManager
  157. '   TriggerCollectionEvent
  158. '   Support #NoEventMgr mode
  159. '   Support #NoDebugMode mode
  160. '   Support ListBox wrapping
  161. '   Support ComboBox wrapping
  162. '   Support UnRegister from EventManager
  163. '   Execute UnRegister Me in GUI Form_QueryUnload()
  164. '   Support .pvtCloseRecordSet
  165. '   AutoDeleteOrphans
  166. '   Implement .Version method
  167. '   ObjMgr.CompleteCleanUp runs too long, redundantly
  168. '
  169. ' Deferred until a later release
  170. '   Lock Manager
  171. '       (not yet needed because Collections are still
  172. '       founded on the RecordSet)
  173. '   SynchronousCommit
  174. '       (same as above)
  175. '   Heterogenous Collections
  176. '       see also SubClasses (below)
  177. '   Instantiating SubClasses
  178. '       Do only "Vehicles", won't do "Cars" or "Buses" or "Trucks", etc.
  179. '   Collection.Sort
  180. '   Separated ComboBoxWrapper functions
  181. '   More properties for ODBC, RecordSet, ListBox,
  182. '       ComboBox, DBGrid, etc.
  183.  
  184. #If NoEventMgr = False Then
  185. Private pvtVBOFEventManager As VBOFEventManager
  186. #End If
  187. Private pvtSystemCollections As New Collection
  188. Private pvtSystemObjects As New Collection
  189. Private pvtSystemWrappers As New Collection
  190. Private pvtDatabase As Database
  191. Private pvtWorkspace As Workspace
  192. Private pvtVBOFCollectionID As Long
  193. Private pvtDebugMode As Boolean
  194. Private pvtVerbose As Boolean
  195. Private pvtAutoDeleteOrphans As Boolean
  196. Private pvtLastAddedObjectWasUnique As Boolean
  197. Private pvtSwapIfEqualSortOrder As Boolean
  198. Private pvtHighestObjectID As Long
  199.  
  200. Public ODBCPassThrough As Boolean
  201. Public ANSISQL As Boolean
  202.  
  203. Private Const pvtReceiverDoesNotSupportThisMethod = 438
  204.  
  205. Public Property Get SwapIfEqualSortOrder() As Boolean
  206.     SwapIfEqualSortOrder = pvtSwapIfEqualSortOrder
  207. End Property
  208.  
  209. Public Property Let SwapIfEqualSortOrder(aBoolean As Boolean)
  210.     pvtSwapIfEqualSortOrder = aBoolean
  211. End Property
  212.  
  213.  
  214. Public Function InitializeObject( _
  215.     Optional Object As Variant) As Boolean
  216. ' Initializes the object in support of
  217. '   VBOF services.
  218. '  Even though the contents of this method may seem
  219. '   trivial, it should still be used because future
  220. '   releases of VBOF will likely contained
  221. '   increased features which may have increased
  222. '   initialization requirements.  Only this method
  223. '   is guaranteed to satisfy those requirements.
  224. '   Thus, having used this method from the outset
  225. '   guarantees the user of transparent object
  226. '   initialization support across future releases.
  227. '
  228. ' Example of usage:
  229. '   Set MyObject = New <appropriateClassModule>
  230. '   ObjectManager.InitializeObject _
  231. '       Object:=MyObject
  232.     
  233.     Set Object.ObjectManager = Me
  234.     
  235.     With Object
  236.         .ObjectParentCount = 1
  237.         .ObjectChanged = False
  238.         .ObjectAdded = False
  239.         .ObjectDeleted = False
  240.     End With
  241.  
  242.     InitializeObject = True
  243. End Function
  244.  
  245. Public Function NewObject( _
  246.     Optional Database As Variant, _
  247.     Optional ObjectID As Variant, _
  248.     Optional Sample As Variant, _
  249.     Optional Parent As Variant, _
  250.     Optional WhereClause As Variant, _
  251.     Optional SQL As Variant, _
  252.     Optional OrderByClause As Variant, _
  253.     Optional ODBCPassThrough As Variant, _
  254.     Optional ANSISQL As Variant) As Variant
  255. ' Returns an instantiated contained Object which
  256. '   occurs only singly within its container object
  257. '   (versus the container object containing a
  258. '   collection of objects of the specified class).
  259. '   This is typical for contained objects
  260. '   such as Employee.Manager, Address.State,
  261. '   Loan.Property, etc.
  262. '
  263. ' Parameter Description:
  264. '   see VBOF User's Guide
  265. '
  266. ' Required Parameters:
  267. '   Sample:=
  268. '   ObjectID:=
  269.     
  270.     Dim tempObject As Object
  271.     Dim tempParent As Object
  272.     Dim tempIndex As Long
  273.     Dim tempRecordSet As RecordSet
  274.     Dim tempODBCPassThrough As Boolean
  275.     Dim SQLStatement As String
  276.     Dim newChildObject As Object
  277.     Dim tempCollectionEmulationMode As Boolean
  278.  
  279.     On Local Error Resume Next
  280.  
  281. ' bullet-proofing
  282.     If IsMissing(Sample) Then
  283.         pvtErrorMessage TypeName(Me) & " cannot process the '.NewObject' method because the 'ObjectID:=' parameter is missing."
  284.         Set NewObject = Nothing
  285.         Exit Function
  286.     End If
  287.     If IsMissing(WhereClause) _
  288.     And IsMissing(ObjectID) Then
  289.         pvtErrorMessage TypeName(Me) & " cannot process the '.NewObject' method because both the 'ObjectID:=' and 'WhereClause:=' parameters are missing."
  290.         Set NewObject = Nothing
  291.         Exit Function
  292.     End If
  293.     tempCollectionEmulationMode = False
  294.     If Sample.ObjectDataSource = "" _
  295.     Or Err = 438 Then
  296.         tempCollectionEmulationMode = True
  297.     End If
  298.     If Not tempCollectionEmulationMode _
  299.     And Not pvtIsDatabaseSpecified() Then
  300.         Set NewObject = Nothing
  301.         Exit Function
  302.     End If
  303.     If IsMissing(ODBCPassThrough) Then
  304.         tempODBCPassThrough = False
  305.     Else
  306.         tempODBCPassThrough = ODBCPassThrough
  307.     End If
  308.     If IsMissing(Parent) Then
  309.         Set tempParent = Nothing
  310.     Else
  311.         Set tempParent = Parent
  312.     End If
  313.  
  314. ' check each of the objects known at this time
  315. '   by their ObjectID
  316.     If Not IsMissing(ObjectID) Then
  317.         If CLng(ObjectID) > 0 Then
  318.             Sample.ObjectID = CLng(ObjectID)
  319.             tempIndex = _
  320.                 pvtObjectIndexInSystemObjects _
  321.                     (Object:=Sample)
  322.         
  323.         ElseIf tempCollectionEmulationMode Then
  324.             tempIndex = -1
  325. '>> huh?
  326.         Else
  327.             Set NewObject = Nothing
  328.             Exit Function
  329.         End If
  330.     Else
  331.         tempIndex = -1
  332.     End If
  333.  
  334. ' if found, return the located object
  335.     If tempIndex > 0 Then
  336.         Set tempObject = _
  337.             pvtSystemObjects.Item _
  338.                 (tempIndex)
  339.  
  340. ' increase the ParentCount of the previously
  341. '   existing object
  342.         tempObject.ObjectParentCount = _
  343.             tempObject.ObjectParentCount + 1
  344.     
  345.         Set NewObject = _
  346.             tempObject
  347.         Exit Function
  348.     End If
  349.  
  350. ' Object wasn't found.
  351. '   try the database
  352. ' Ensure the object is ready for Database access
  353.     If tempCollectionEmulationMode Then
  354.         
  355. ' have the Sample Object return an instantiated
  356. '   copy of itself
  357.         Set newChildObject = _
  358.             Me.pvtInstantiateNewObjectFromSample _
  359.                  (Sample:=Sample)
  360.         If newChildObject Is Nothing Then
  361.             Set NewObject = Nothing
  362.             Exit Function
  363.         End If
  364.     
  365. ' assign an artificial ObjectID
  366.         newChildObject.ObjectID = _
  367.             pvtNextObjectID
  368.     
  369. ' add the object to the SystemObjects Collection
  370.         Set NewObject = _
  371.             pvtAddUniqueObject( _
  372.                 Object:=newChildObject, _
  373.                 Parent:=tempParent)
  374.         Exit Function
  375.     End If
  376.     
  377. ' must retrieve it from the database
  378.     SQLStatement = _
  379.         "SELECT * FROM " & _
  380.         Sample.ObjectDataSource & _
  381.         " WHERE "
  382.     If Not IsMissing(ObjectID) Then
  383.         SQLStatement = _
  384.             SQLStatement & _
  385.                 "ObjectID = " & _
  386.                 CStr(ObjectID)
  387.     ElseIf Not IsMissing(WhereClause) Then
  388.         SQLStatement = _
  389.             SQLStatement & _
  390.                 WhereClause
  391.     End If
  392.     
  393. ' retrieve the data row
  394.     Set tempRecordSet = _
  395.         pvtDatabase. _
  396.             OpenRecordset( _
  397.                 SQLStatement, _
  398.                 dbOpenDynaset + pvtODBCPassThrough(tempODBCPassThrough))
  399.         
  400. ' check for NoRecords
  401.     If tempRecordSet.RecordCount < 1 Then
  402.         Set NewObject = Nothing
  403.         Exit Function
  404.     End If
  405.         
  406. ' have the Sample Object return an instantiated
  407. '   copy of itself
  408.     Set newChildObject = _
  409.         Me.pvtInstantiateNewObjectFromSample _
  410.              (Sample:=Sample)
  411.     If newChildObject Is Nothing Then
  412.         Set NewObject = Nothing
  413.         Exit Function
  414.     End If
  415.         
  416. ' initialize the NewChild.ObjectID temporarily
  417. '   so the pvtAddUniqueObject will register the
  418. '   correct ObjectID (and avoid an endless loop
  419. '   in the case of SpouseA <-> SpouseB)
  420.     newChildObject.ObjectID = ObjectID
  421.     
  422. ' add the object to the SystemObjects Collection
  423.     Set tempObject = _
  424.         pvtAddUniqueObject( _
  425.             Object:=newChildObject, _
  426.             Parent:=tempParent)
  427.  
  428. ' have the new instantiated object copy populate
  429. '   itself from this RecordSet row
  430.     Set newChildObject = _
  431.         Me.pvtObjectInitializeFromRecordSet( _
  432.             Object:=newChildObject, _
  433.             RecordSet:=tempRecordSet)
  434.     If newChildObject Is Nothing Then
  435.         Set NewObject = Nothing
  436.         Exit Function
  437.     End If
  438.     
  439.     Set NewObject = _
  440.         tempObject
  441. End Function
  442.  
  443. Public Function ObjectSortCompare( _
  444.     Optional Value1 As Variant, _
  445.     Optional Value2 As Variant, _
  446.     Optional SortOrder As Variant) As Long
  447. ' (In support of the application objects'
  448. '   ObjectSortCompare method)
  449. ' Performs a comparison of the two values and
  450. '   returns the value -1, 0 or 1, as needed by the
  451. '   application objects in support of the
  452. '   Collection.Sort method
  453.     
  454.     Dim tempSortOrder As String
  455.     
  456. ' bullet-proofing
  457.     If IsMissing(Value1) Then
  458.         DisplayErrorMessage TypeName(Me) & " cannot process the '.ObjectSortCompare' method because the 'Value1:=' parameter is missing."
  459.         Exit Function
  460.     End If
  461.     If IsMissing(Value2) Then
  462.         DisplayErrorMessage TypeName(Me) & " cannot process the '.ObjectSortCompare' method because the 'Value2:=' parameter is missing."
  463.         Exit Function
  464.     End If
  465.     If IsMissing(SortOrder) Then
  466.         tempSortOrder = "ASC"
  467.     Else
  468.         tempSortOrder = SortOrder
  469.     End If
  470.     
  471. ' compare the values
  472.     If Value1 < Value2 Then
  473.         ObjectSortCompare = -1
  474.     ElseIf Value1 > Value2 Then
  475.         ObjectSortCompare = 1
  476.     Else
  477.         ObjectSortCompare = 0
  478.     End If
  479.     
  480. ' reverse the answer if processing "DESC"
  481.     If Mid$(tempSortOrder, 1, 1) = "D" Then
  482.         ObjectSortCompare = _
  483.             ObjectSortCompare * -1
  484.     End If
  485. End Function
  486.  
  487. Public Function pvtChooseObjectIDFromParameters( _
  488.     Optional ObjectID As Variant, _
  489.     Optional Object As Variant, _
  490.     Optional Item As Variant, _
  491.     Optional ReturnObjectID As Variant) As Boolean
  492.  
  493.     Dim tempObjectRequested As Boolean
  494.     Dim tempObjectID As Variant
  495.  
  496.     tempObjectRequested = False
  497.  
  498. ' support Object:=, ObjectID:= and Item:=
  499.     If Not IsMissing(ObjectID) Then
  500.         tempObjectID = ObjectID
  501.         tempObjectRequested = True
  502.     ElseIf Not IsMissing(Item) Then
  503.         tempObjectID = Item.ObjectID
  504.         tempObjectRequested = True
  505.     ElseIf Not IsMissing(Object) Then
  506.         tempObjectID = Object.ObjectID
  507.         tempObjectRequested = True
  508.     End If
  509.  
  510. ' if one of the above was specified,
  511. '   save the ObjectID
  512.     If tempObjectRequested Then
  513.         ReturnObjectID = tempObjectID
  514.     End If
  515.     
  516.     pvtChooseObjectIDFromParameters = _
  517.         tempObjectRequested
  518. End Function
  519.  
  520. Public Function pvtConvertToLongOrLeaveAlone(Value As Variant) As Variant
  521.     If InStr("Long Integer", TypeName(Value)) > 0 Then
  522.         pvtConvertToLongOrLeaveAlone = CLng(Value)
  523.     Else
  524.         pvtConvertToLongOrLeaveAlone = Value
  525.     End If
  526. End Function
  527.  
  528. Public Function pvtChooseObjectFromParameters( _
  529.     Optional Object As Variant, _
  530.     Optional Item As Variant, _
  531.     Optional ReturnObject As Variant) As Boolean
  532.  
  533.     Dim tempObjectRequested As Boolean
  534.     Dim tempObject As Variant
  535.  
  536.     tempObjectRequested = False
  537.  
  538. ' support Object:= and Item:=
  539.     If Not IsMissing(Item) Then
  540.         If TypeName(Item) = "String" Then
  541.             ReturnObject = Item
  542.             tempObjectRequested = True
  543.         ElseIf TypeName(Item) = "Long" Then
  544.             ReturnObject = Item
  545.             tempObjectRequested = True
  546.         ElseIf TypeName(Item) = "Integer" Then
  547.             ReturnObject = Item
  548.             tempObjectRequested = True
  549.         ElseIf InStr("Nothing Empty", TypeName(Item)) <> 0 Then
  550.             Set ReturnObject = Nothing
  551.             tempObjectRequested = False
  552.         Else
  553.             Set ReturnObject = Item
  554.             tempObjectRequested = True
  555.         End If
  556.     ElseIf Not IsMissing(Object) Then
  557.         Set ReturnObject = Object
  558.         tempObjectRequested = True
  559.     End If
  560.     
  561.     pvtChooseObjectFromParameters = _
  562.         tempObjectRequested
  563. End Function
  564.  
  565.  
  566. Public Function pvtNextObjectID() As Long
  567.         pvtHighestObjectID = _
  568.             pvtHighestObjectID + 1
  569.             
  570.         If pvtHighestObjectID <= 0 Then
  571.             pvtHighestObjectID = 1
  572.         End If
  573.             
  574.         pvtSaveHighestObjectID pvtHighestObjectID
  575.         
  576.         pvtNextObjectID = _
  577.             pvtHighestObjectID
  578. End Function
  579.  
  580.  
  581. Public Function pvtObjectInitializeFromRecordSet( _
  582.     Optional Object As Variant, _
  583.     Optional RecordSet As Variant) As Variant
  584.  
  585.     On Local Error Resume Next
  586.     
  587. ' have the object copy populate
  588. '   itself from this RecordSet row
  589.     Object _
  590.         .ObjectInitializeFromRecordSet (RecordSet)
  591.     If Err = pvtReceiverDoesNotSupportThisMethod Then
  592.         pvtErrorMessage "Class Module '" & TypeName(Object) & "' does not support the method 'InitializeFromRecordSet'." & vbCrLf & "Object cannot be supported by VBOF without this method."
  593.         Set pvtObjectInitializeFromRecordSet = Nothing
  594.         Exit Function
  595.     End If
  596.  
  597.     Set pvtObjectInitializeFromRecordSet = Object
  598. End Function
  599.  
  600. Public Function pvtInstantiateNewObjectFromSample( _
  601.     Optional Sample As Variant) As Variant
  602.  
  603.     On Local Error Resume Next
  604.  
  605. ' instantiate the new object
  606.     Set pvtInstantiateNewObjectFromSample = _
  607.         Sample. _
  608.             ObjectNewInstanceOfMyClass
  609.     If Err = pvtReceiverDoesNotSupportThisMethod Then
  610.         pvtErrorMessage "Class Module '" & TypeName(Sample) & "' does not support the method 'ObjectNewInstanceOfMyClass'." & vbCrLf & "Object cannot be supported by " & TypeName(Me) & " without this method."
  611.         Set pvtInstantiateNewObjectFromSample = Nothing
  612.         Exit Function
  613.     End If
  614.  
  615.     Set pvtInstantiateNewObjectFromSample. _
  616.         ObjectManager = Me
  617. End Function
  618.  
  619. Public Function ManageCollection( _
  620.     Optional Collection As Variant, Optional ObjectID As Variant, _
  621.     Optional Item As Variant, Optional Object As Variant, _
  622.     Optional Database As Variant, Optional Sample As Variant, _
  623.     Optional Parent As Variant, Optional WhereClause As Variant, _
  624.     Optional SQL As Variant, Optional OrderByClause As Variant, _
  625.     Optional CollectionEmulationMode As Variant, Optional ANSISQL As Variant, _
  626.     Optional ODBCPassThrough As Variant) As Variant
  627. ' Returns the entire collection if the ObjectID
  628. '   parameter is missing,
  629. '   or
  630. ' Returns a Person object whose ObjectID matches the
  631. '   ObjectID parameter.
  632. '
  633. ' Completely manages a contained Collection of
  634. '   objects on behalf of a given containing object
  635. '
  636. ' Example of usage:
  637. '    Public Function Persons(Optional ObjectID As Variant) As Variant
  638. '    Dim tempNewPerson As New Person
  639. '    Set Persons = _
  640. '        ObjectManager. _
  641. '            ManageCollection( _
  642. ' (R)            Collection:=myPersonsCollection,
  643. ' (R)            Parent:=Me,
  644. ' (O)            ObjectID:=ObjectID,
  645. ' (O)            Object:=tempObject,
  646. ' (O)            Item:=tempObject,
  647. ' (O)            Sample:=tempNewPerson,
  648. ' (O)            Database:=MyDatabase,
  649. ' (O)            SQL:=sql statement,
  650. ' (O)            OrderByClause:="LastName ASC, FirstName ASC",
  651. ' (O)            WhereClause:=where clause,
  652. ' (O)            ANSISQL:=True|False,
  653. ' (O)            ODBCPassThrough:=True|False
  654. '
  655. ' Parameter Description:
  656. '   Collection:= (Required) the VBOFCollection object
  657. '       to be managed
  658. '   Parent:= (Required) defines the object which is
  659. '       the "Parent" of the objects to be collected.
  660. '       The value to specify is typically "Me".
  661. '       In OO terminology, this is the "containing"
  662. '       object
  663. '   Database:= (Optional) the VB Database Object containing
  664. '       the necessary Table
  665. '   ObjectID:= (Optional) the ObjectID value of the
  666. '       desired object.  If not provided, the entire
  667. '       VBOFCollection is returned
  668. '   Item:= (Optional) can be used in lieu of the
  669. '       ObjectID:= parameter.  Refers to the object
  670. '       to be returned.  See also the ObjectID:=
  671. '       parameter.
  672. '   Object:= (Optional) can be used in lieu of the
  673. '       ObjectID:= parameter.  Refers to the object
  674. '       to be returned.  See also the ObjectID:=
  675. '       parameter.
  676. '   Sample:= (Optional, but recommended) a
  677. '       throw-away object of the desired Class which
  678. '       VBOFCollection can use to help instantiate
  679. '       new objects to be placed into the
  680. '       Collection
  681. '   WhereClause:= (Optional) defines the SQL Where
  682. '       Clause to be used to select the desired
  683. '       rows from the Table.
  684. '       Normally, VBOFCollection creates all
  685. '       necessary Where Clauses to effect containment
  686. '   SQL:= (Optional, not recommended) defines the
  687. '       SQL statement to be used to select the
  688. '       desired rows from the Table.
  689. '       Normally, VBOFCollection creates the
  690. '       necessary SQL statement to effect containment
  691. '   OrderByClause:= (Optional) defines the SQL Order
  692. '       By Clause to be used to select the desired
  693. '       rows from the Table.
  694. '       Normally, VBOFCollection does not provide an
  695. '       Order By Clause
  696. '   ANSISQL:= (Optional) control whether or not
  697. '       ANSI SQL should be used when linking objects
  698. '       for containment purposes
  699. '   ODBCPassThrough:= (Optional) controls whether
  700. '       of not the SQL statements used by
  701. '       VBOFCollection to link parent and child objects
  702. '       should be executed on an ODBC database server
  703.  
  704.     Dim tempDatabase As Database
  705.     Dim tempObjectRequested As Boolean
  706.     Dim tempObjectID As Variant
  707.  
  708.     On Local Error Resume Next
  709.  
  710. ' bullet-proofing
  711.     If IsMissing(Collection) _
  712.     Or IsMissing(Parent) _
  713.     Or IsMissing(Sample) Then
  714.         pvtErrorMessage TypeName(Me) & " cannot process the '.ManageCollection' method because either the 'Collection:=', 'Parent:=' or 'Sample:=' parameter is missing."
  715.         Set ManageCollection = Nothing
  716.         Exit Function
  717.     End If
  718.  
  719. ' use a valid Database parameter
  720.     If Not IsMissing(Database) Then
  721.         Set tempDatabase = Database
  722.     Else
  723.         Set tempDatabase = pvtDatabase
  724.     End If
  725.  
  726. ' check for never-before referenced Collection
  727.     If Collection Is Nothing Then
  728.         Set Collection = _
  729.             ObjectManager.NewVBOFCollection _
  730.                 (Parent:=Parent)
  731.     End If
  732.     
  733. ' check for the need to populate the collection
  734. '   from the database
  735.     If Not Collection. _
  736.             pvtDatabaseHasBeenReferenced Then
  737.  
  738. ' pass-along any known Database parameters
  739.         Collection.SetDatabaseParameters _
  740.             Database:=tempDatabase, _
  741.             SQL:=SQL, _
  742.             ANSISQL:=ANSISQL, _
  743.             WhereClause:=WhereClause, _
  744.             OrderByClause:=OrderByClause, _
  745.             ODBCPassThrough:=ODBCPassThrough
  746.  
  747. ' instantiate the contained objects
  748.         Set Collection = _
  749.             Collection.PopulateCollection( _
  750.                 Database:=tempDatabase, _
  751.                 Parent:=Parent, _
  752.                 Sample:=Sample)
  753.     End If
  754.     
  755. ' check for a request for a specific Object
  756.     If pvtChooseObjectIDFromParameters( _
  757.         Item:=Item, _
  758.         Object:=Object, _
  759.         ObjectID:=ObjectID, _
  760.         ReturnObjectID:=tempObjectID) _
  761.     Then
  762.         Set ManageCollection = _
  763.             Collection.Item _
  764.                 (pvtConvertToLongOrLeaveAlone _
  765.                     (tempObjectID))
  766. '>>        If InStr("Long Integer", TypeName(tempObjectID)) > 0 Then
  767. '            Set ManageCollection = _
  768.                 Collection.Item _
  769.                     (tempObjectID)
  770. '        Else
  771. '            Set ManageCollection = _
  772.                 Collection.Item _
  773.                     (ObjectID:=CStr(tempObjectID))
  774. '        End If
  775.  
  776. ' else, return the entire collection
  777.     Else
  778.         Set ManageCollection = _
  779.             Collection
  780.     End If
  781. End Function
  782.  
  783. Private Function pvtRegisterWrapperUnderForm( _
  784.     Optional Form As Variant, _
  785.     Optional Wrapper As Variant) As Boolean
  786. ' NOT CURRENTLY SUPPORTED
  787. ' register the wrapper for future automatic
  788. '   deletion as the Form terminates (through
  789. '   TerminateForm)
  790.     
  791.     On Local Error Resume Next
  792.     
  793.     If Not IsMissing(Form) Then
  794.         If Not Form Is Nothing Then
  795.             pvtSystemWrappers.Add _
  796.                 Item:=Wrapper, _
  797.                 Key:=CStr(Wrapper.ObjectID)
  798.                 
  799.             Set Wrapper.Form = _
  800.                 Form
  801.         End If
  802.     End If
  803.  
  804.     pvtRegisterWrapperUnderForm = True
  805. End Function
  806.  
  807. Public Sub pvtSaveHighestObjectID( _
  808.     Optional ObjectID As Variant)
  809.     If ObjectID > pvtHighestObjectID Then
  810.         pvtHighestObjectID = ObjectID
  811.     End If
  812. End Sub
  813.  
  814. Public Function pvtUnRegisterWrapperUnderForm( _
  815.     Optional Form As Variant, _
  816.     Optional Wrapper As Variant) As Boolean
  817. ' NOT CURRENTLY SUPPORTED
  818. ' unregister the wrapper from the Form
  819.     
  820.     Dim tempWrapper As Variant
  821.     
  822.     On Local Error Resume Next
  823.     
  824.     pvtUnRegisterWrapperUnderForm = False
  825.     
  826. ' bullet-proofing
  827.     If IsMissing(Form) Then
  828.         Exit Function
  829.     ElseIf Form Is Nothing Then
  830.         Exit Function
  831.     ElseIf IsMissing(Wrapper) Then
  832.         Exit Function
  833.     ElseIf Wrapper Is Nothing Then
  834.         Exit Function
  835.     End If
  836.     
  837. ' search for the wrapper
  838.     For Each tempWrapper In pvtSystemWrappers
  839.     
  840. ' unregister it
  841.         If tempWrapper.ObjectID = Wrapper.ObjectID Then
  842.             Set tempWrapper.Form = Nothing
  843.             
  844.             pvtSystemWrappers.Remove _
  845.                 CStr(tempWrapper.ObjectID)
  846.             
  847.             pvtUnRegisterWrapperUnderForm = True
  848.             Exit Function
  849.         End If
  850.     Next tempWrapper
  851. End Function
  852.  
  853. Public Function pvtWrapperSort( _
  854.     Optional Wrapper As Variant, _
  855.     Optional SortField As Variant, _
  856.     Optional SortOrder As Variant) As Boolean
  857.     
  858.     Dim tempBoolean As Boolean
  859.  
  860.     tempBoolean = _
  861.         Wrapper.Collection.Sort( _
  862.             SortField:=SortField, _
  863.             SortOrder:=SortOrder)
  864.             
  865.     If Not tempBoolean Then
  866.         pvtWrapperSort = False
  867.         Exit Function
  868.     End If
  869.     
  870.     Wrapper.Refresh _
  871.         DisplayOnly:=True
  872.  
  873.     pvtWrapperSort = True
  874. End Function
  875.  
  876. Public Function pvtWrapperUseCollection( _
  877.     Optional CollectionParm As Variant, _
  878.     Optional pvtCollection As Variant, _
  879.     Optional Verbose As Variant, _
  880.     Optional WrapperName As Variant) As Variant
  881.  
  882.     On Local Error Resume Next
  883.  
  884.     If Not IsMissing(CollectionParm) Then
  885.         If Not CollectionParm Is Nothing Then
  886.             If TypeName(CollectionParm) = _
  887.                 "VBOFCollection" _
  888.             Then
  889.                 Set pvtCollection = CollectionParm
  890.                 Set pvtWrapperUseCollection = pvtCollection
  891.                 Exit Function
  892.             End If
  893.         End If
  894.     End If
  895.     
  896.     If Not IsMissing(pvtCollection) Then
  897.         If Not pvtCollection Is Nothing Then
  898.             If TypeName(pvtCollection) = _
  899.                 "VBOFCollection" _
  900.             Then
  901.                 Set pvtWrapperUseCollection = pvtCollection
  902.                 Exit Function
  903.             End If
  904.         End If
  905.     End If
  906.     
  907. ' error
  908.     If Not IsMissing(Verbose) Then
  909.         If Verbose Then
  910.             pvtErrorMessage TypeName(Me) & " cannot process the " & WrapperName & " methods because the 'Collection' parameter is missing and no suitable default has been established." & vbCrLf & vbCrLf & "If using the VBOF" & WrapperName & "Wrapper, please ensure that the 'ObjectManager.NewVBOF" & WrapperName & "Wrapper' method has been properly executed and references the appropriate Collection and " & WrapperName & " control."
  911.         End If
  912.     End If
  913.     
  914.     Set pvtWrapperUseCollection = Nothing
  915. End Function
  916.  
  917. Public Function pvtWrapperUseControl( _
  918.     Optional ControlParm As Variant, _
  919.     Optional pvtControl As Variant, _
  920.     Optional SupportedNames As Variant, _
  921.     Optional WrapperName As Variant, _
  922.     Optional Verbose As Variant) As Variant
  923.  
  924.     On Local Error Resume Next
  925.  
  926.     If Not IsMissing(ControlParm) Then
  927.         If Not ControlParm Is Nothing Then
  928.             If InStr(SupportedNames, TypeName(ControlParm)) > 0 Then
  929.                 Set pvtControl = ControlParm
  930.                 Set pvtWrapperUseControl = pvtControl
  931.                 Exit Function
  932.             End If
  933.         End If
  934.     End If
  935.     
  936.     If Not IsMissing(pvtControl) Then
  937.         If Not pvtControl Is Nothing Then
  938.             If InStr(SupportedNames, TypeName(pvtControl)) > 0 Then
  939.                 Set pvtWrapperUseControl = pvtControl
  940.                 Exit Function
  941.             End If
  942.         End If
  943.     End If
  944.     
  945. ' error
  946.     If Not IsMissing(Verbose) Then
  947.         If Verbose Then
  948.             pvtErrorMessage TypeName(Me) & " cannot process the " & WrapperName & " methods because the '" & WrapperName & "' parameter is missing and no suitable default has been established." & vbCrLf & vbCrLf & "If using the VBOF" & WrapperName & "Wrapper, please ensure that the 'ObjectManager.NewVBOF" & WrapperName & "Wrapper' method has been properly executed and references the appropriate Collection and " & WrapperName & " control."
  949.         End If
  950.     End If
  951.     
  952.     Set pvtWrapperUseControl = Nothing
  953. End Function
  954.  
  955. Public Function pvtWrapperVerifyCollection( _
  956.     Optional Collection As Variant, _
  957.     Optional pvtCollection As Variant, _
  958.     Optional Verbose As Variant, _
  959.     Optional WrapperName As Variant) As Boolean
  960.  
  961.     Dim tempCollection As Variant
  962.  
  963.     If Not IsMissing(Collection) Then
  964.         Set tempCollection = Collection
  965.     Else
  966.         Set tempCollection = pvtCollection
  967.     End If
  968.  
  969.     If pvtWrapperUseCollection( _
  970.         CollectionParm:=tempCollection, _
  971.         pvtCollection:=pvtCollection, _
  972.         Verbose:=Verbose, _
  973.         WrapperName:=WrapperName) Is Nothing _
  974.     Then
  975.         pvtWrapperVerifyCollection = False
  976.     Else
  977.         pvtWrapperVerifyCollection = True
  978.     End If
  979. End Function
  980.  
  981. Public Function pvtWrapperVerifyControl( _
  982.     Optional Control As Variant, _
  983.     Optional pvtControl As Variant, _
  984.     Optional Verbose As Variant, _
  985.     Optional WrapperName As Variant) As Boolean
  986.  
  987.     Dim tempControl As Variant
  988.  
  989.     If Not IsMissing(Control) Then
  990.         Set tempControl = Control
  991.     Else
  992.         Set tempControl = pvtControl
  993.     End If
  994.  
  995.     If pvtWrapperUseControl( _
  996.         ControlParm:=tempControl, _
  997.         pvtControl:=pvtControl, _
  998.         Verbose:=Verbose, _
  999.         WrapperName:=WrapperName) Is Nothing _
  1000.     Then
  1001.         pvtWrapperVerifyControl = False
  1002.     Else
  1003.         pvtWrapperVerifyControl = True
  1004.     End If
  1005. End Function
  1006.  
  1007.  
  1008. Public Function NewVBOFRecordSetWrapper( _
  1009.     Optional Collection As Variant, _
  1010.     Optional DataControl As Variant, _
  1011.     Optional Form As Variant _
  1012.     ) As VBOFDataWrapper
  1013. ' Returns a new VBOFRecordSetlWrapper for the
  1014. '   specified VBOFCollection
  1015. '
  1016. ' Coding Example:
  1017. '   Dim MyRecordSetWrapper as VBOFRecordSetWrapper
  1018. '   Dim MyCollection as VBOFCollection
  1019. '   Set MyRecordSetWrapper = _
  1020. '       ObjectManager.NewVBOFRecordSetWrapper ( _
  1021. '           Collection:=MyCollection)
  1022.  
  1023.     Dim tempNewRecordSetWrapper As New VBOFRecordSetWrapper
  1024.     
  1025.     Set tempNewRecordSetWrapper.ObjectManager = Me
  1026.     
  1027. ' bullet-proofing
  1028. '    If IsMissing(Collection) Then
  1029. '        pvtErrorMessage TypeName(Me) & " cannot process the '.NewVBOFRecordSetWrapper' method because the 'Collection:=' parameter is missing."
  1030. '        Set NewVBOFRecordSetWrapper = Nothing
  1031. '        Exit Function
  1032. '    End If
  1033.  
  1034. ' initialize the Collection
  1035.     If Not IsMissing(Collection) Then
  1036.         If Not Collection Is Nothing Then
  1037.             Set tempNewRecordSetWrapper.Collection = _
  1038.                 Collection
  1039.         End If
  1040.     End If
  1041.     
  1042. ' have the new wrapper bind itself to the RecordSet
  1043.     If Not tempNewRecordSetWrapper.Collection Is Nothing Then
  1044.         tempNewRecordSetWrapper.Rebind
  1045.     End If
  1046.     
  1047. ' generate a unique ObjectID for the new VBOFListBoxWrapper
  1048.     pvtVBOFCollectionID = _
  1049.         pvtVBOFCollectionID + 1
  1050.     tempNewRecordSetWrapper.ObjectID = _
  1051.         pvtVBOFCollectionID
  1052.     
  1053. ' register the wrapper for future automatic
  1054. '   deletion as the Form terminates (through
  1055. '   TerminateForm)
  1056. '    pvtRegisterWrapperUnderForm _
  1057.         Form:=Form, _
  1058.         Wrapper:=tempNewRecordSetWrapper
  1059.     
  1060.     Set NewVBOFRecordSetWrapper = _
  1061.         tempNewRecordSetWrapper
  1062. End Function
  1063.  
  1064. Public Function NewVBOFDBGridWrapper( _
  1065.     Optional Collection As Variant, _
  1066.     Optional DBGrid As Variant, _
  1067.     Optional Form As Variant _
  1068.     ) As VBOFDBGridWrapper
  1069. ' Returns a new VBOFDBGridWrapper for the
  1070. '   specified VBOFCollection (Required) and
  1071. '   DBGrid (Optional)
  1072. '
  1073. ' Coding Example:
  1074. '   Dim MyDBGridWrapper as VBOFDBGridWrapper
  1075. '   Dim MyCollection as VBOFCollection
  1076. '   Set MyDBGridWrapper = _
  1077. '       ObjectManager.NewVBOFDBGridWrapper ( _
  1078. '           Collection:=MyCollection, _
  1079. '           DBGrid:=MyDBGrid)
  1080.  
  1081.     Dim tempNewDBGridWrapper As New VBOFDBGridWrapper
  1082.     
  1083.     Set tempNewDBGridWrapper.ObjectManager = Me
  1084.     
  1085. ' bullet-proofing
  1086. '    If IsMissing(Collection) Then
  1087. '        pvtErrorMessage TypeName(Me) & " cannot process the '.NewVBOFDBGridWrapper' method because the 'Collection:=' parameter is missing."
  1088. '        Set NewVBOFDBGridWrapper = Nothing
  1089. '        Exit Function
  1090. '    End If
  1091. '    If IsMissing(DBGrid) Then
  1092. '        pvtErrorMessage TypeName(Me) & " cannot process the '.NewVBOFDBGridWrapper' method because the 'DBGrid:=' parameter is missing."
  1093. '        Set NewVBOFDBGridWrapper = Nothing
  1094. '        Exit Function
  1095. '    End If
  1096.  
  1097. ' initialize the Collection
  1098.     If Not IsMissing(Collection) Then
  1099.         If Not Collection Is Nothing Then
  1100.             Set tempNewDBGridWrapper.Collection = _
  1101.                 Collection
  1102.         End If
  1103.     End If
  1104.     
  1105.     If Not IsMissing(DBGrid) Then
  1106.         If Not DBGrid Is Nothing Then
  1107.             Set tempNewDBGridWrapper.DBGrid = _
  1108.                 DBGrid
  1109.         End If
  1110.     End If
  1111.     
  1112. ' have the new wrapper bind itself to the DBGrid
  1113.     If Not tempNewDBGridWrapper.DBGrid Is Nothing Then
  1114.         If Not tempNewDBGridWrapper.Collection Is Nothing Then
  1115.             tempNewDBGridWrapper.Rebind _
  1116.                 Collection:=Collection, _
  1117.                 DBGrid:=DBGrid
  1118.         End If
  1119.     End If
  1120.     
  1121. ' generate a unique ObjectID for the new VBOFDBGridWrapper
  1122.     pvtVBOFCollectionID = _
  1123.         pvtVBOFCollectionID + 1
  1124.     tempNewDBGridWrapper.ObjectID = _
  1125.         pvtVBOFCollectionID
  1126.     
  1127. ' register the wrapper for future automatic
  1128. '   deletion as the Form terminates (through
  1129. '   TerminateForm)
  1130. '    pvtRegisterWrapperUnderForm _
  1131.         Form:=Form, _
  1132.         Wrapper:=tempNewDBGridWrapper
  1133.     
  1134.     Set NewVBOFDBGridWrapper = _
  1135.         tempNewDBGridWrapper
  1136. End Function
  1137.  
  1138. Private Function pvtIsDatabaseSpecified() As Integer
  1139. ' Determine whether or not the database has been
  1140. '   specified
  1141.  
  1142.     If pvtDatabase Is Nothing Then
  1143. '        pvtErrorMessage TypeName(Me) & " cannot function without having been provided the name of the database.  Use the 'Database:=' parameter to specify the database."
  1144.         pvtIsDatabaseSpecified = False
  1145.         Exit Function
  1146.     End If
  1147.  
  1148.     pvtIsDatabaseSpecified = True
  1149. End Function
  1150.  
  1151.  
  1152. Public Function Collection( _
  1153.     Optional ObjectID As Variant, _
  1154.     Optional Index As Variant) As VBOFCollection
  1155. ' Return the VBOFCollection having the specified
  1156. '   ObjectID or Index
  1157.  
  1158.     On Local Error Resume Next
  1159.     
  1160.     Set Collection = Nothing
  1161.     
  1162. ' bullet-proofing
  1163.     If IsMissing(ObjectID) And IsMissing(Index) Then
  1164.         pvtErrorMessage TypeName(Me) & " cannot process the '.Collection' method because the 'ObjectID:=' and the 'Index:=' parameters were missing."
  1165.         Exit Function
  1166.     End If
  1167.  
  1168.     If Not IsMissing(Index) Then
  1169.         Set Collection = _
  1170.             pvtSystemCollections(Index)
  1171.     
  1172.     ElseIf Not IsMissing(ObjectID) Then
  1173.         Set Collection = _
  1174.             pvtSystemCollections(CStr(ObjectID))
  1175.     End If
  1176.  
  1177. End Function
  1178.  
  1179. Public Function CompleteObjectCleanUp() As Boolean
  1180. Attribute CompleteObjectCleanUp.VB_Description = "Private"
  1181. ' Removes all known Collections and Objects from the
  1182. '   current environment
  1183. ' Note: does NOT sever the automatic object
  1184. '   containment links between containing objects and
  1185. '   contained objects
  1186.  
  1187.     Dim tempCollection As VBOFCollection
  1188.     
  1189.     On Local Error Resume Next
  1190.     
  1191.     For Each tempCollection In pvtSystemCollections
  1192.         
  1193.         RemoveCollection _
  1194.             Collection:=tempCollection, _
  1195.             NoDelete:=True, _
  1196.             CleanUpMode:=True
  1197.     
  1198.         pvtSystemCollections.Remove 1
  1199.     
  1200.     Next tempCollection
  1201.  
  1202.     CompleteObjectCleanUp = True
  1203. End Function
  1204.  
  1205. Public Function DisplayDebugMessage( _
  1206.     Optional Message As Variant) As Long
  1207.  
  1208. #If NoDebugMode = False Then
  1209.     DisplayDebugMessage = True
  1210.  
  1211.     If Not pvtDebugMode Then
  1212.         Exit Function
  1213.     End If
  1214.     
  1215.     Debug.Print Format$(Now, "yyyy/mm/dd hh:nn:ss") & " " & Message
  1216. #Else
  1217.     If Verbose Then
  1218.         DisplayErrorMessage TypeName(Me) & " (Warning) the .DisplayDebugMessage method has been executed, but the conditional compilation parameter 'NoDebugMode = -1' has been specified.  No Event code is generated unless 'NoDebugMode = 0' or 'NoDebugMode' is missing from the conditional compilation string altogether."
  1219.     End If
  1220. #End If
  1221. End Function
  1222.  
  1223.  
  1224. Public Function NewVBOFListBoxWrapper( _
  1225.     Optional Collection As Variant, _
  1226.     Optional ListBox As Variant, _
  1227.     Optional Form As Variant _
  1228.     ) As VBOFListBoxWrapper
  1229. ' Returns a new VBOFListBoxWrapper for the
  1230. '   specified VBOFCollection (Required) and
  1231. '   ListBox (Optional)
  1232. '
  1233. ' Coding Example:
  1234. '   Dim MyListBoxWrapper as VBOFListBoxWrapper
  1235. '   Dim MyCollection as VBOFCollection
  1236. '   Set MyListBoxWrapper = _
  1237. '       ObjectManager.NewVBOFListBoxWrapper ( _
  1238. '           Collection:=MyCollection, _
  1239. '           ListBox:=MyListBox)
  1240.  
  1241.     Dim tempNewListBoxWrapper As New VBOFListBoxWrapper
  1242.     
  1243.     Set tempNewListBoxWrapper.ObjectManager = Me
  1244.     
  1245. ' bullet-proofing
  1246. '    If IsMissing(Collection) Then
  1247. '        pvtErrorMessage TypeName(Me) & " cannot process the '.NewVBOFListBoxWrapper' method because the 'Collection:=' parameter is missing."
  1248. '        Set NewVBOFListBoxWrapper = Nothing
  1249. '        Exit Function
  1250. '    End If
  1251. '    If IsMissing(ListBox) Then
  1252. '        pvtErrorMessage TypeName(Me) & " cannot process the '.NewVBOFListBoxWrapper' method because the 'ListBox:=' parameter is missing."
  1253. '        Set NewVBOFListBoxWrapper = Nothing
  1254. '        Exit Function
  1255. '    End If
  1256.  
  1257. ' initialize the Collection
  1258.     If Not IsMissing(Collection) Then
  1259.         If Not Collection Is Nothing Then
  1260.             Set tempNewListBoxWrapper.Collection = _
  1261.                 Collection
  1262.         End If
  1263.     End If
  1264.     
  1265.     If Not IsMissing(ListBox) Then
  1266.         If Not ListBox Is Nothing Then
  1267.             Set tempNewListBoxWrapper.ListBox = _
  1268.                 ListBox
  1269.         End If
  1270.     End If
  1271.     
  1272. ' have the new wrapper bind itself to the ListBox
  1273.     If Not tempNewListBoxWrapper.ListBox Is Nothing Then
  1274.         If Not tempNewListBoxWrapper.Collection Is Nothing Then
  1275.             tempNewListBoxWrapper.Rebind _
  1276.                 Collection:=Collection, _
  1277.                 ListBox:=ListBox
  1278.         End If
  1279.     End If
  1280.     
  1281. ' generate a unique ObjectID for the new VBOFListBoxWrapper
  1282.     pvtVBOFCollectionID = _
  1283.         pvtVBOFCollectionID + 1
  1284.     tempNewListBoxWrapper.ObjectID = _
  1285.         pvtVBOFCollectionID
  1286.     
  1287. ' register the wrapper for future automatic
  1288. '   deletion as the Form terminates (through
  1289. '   TerminateForm)
  1290. '    pvtRegisterWrapperUnderForm _
  1291.         Form:=Form, _
  1292.         Wrapper:=tempNewListBoxWrapper
  1293.     
  1294.     Set NewVBOFListBoxWrapper = _
  1295.         tempNewListBoxWrapper
  1296. End Function
  1297.  
  1298. Public Function NewVBOFDataWrapper( _
  1299.     Optional Collection As Variant, _
  1300.     Optional DataControl As Variant, _
  1301.     Optional Form As Variant _
  1302.     ) As VBOFDataWrapper
  1303. ' Returns a new VBOFDataWrapper for the
  1304. '   specified VBOFCollection, and optionally the
  1305. '   DataControl
  1306. '
  1307. ' Coding Example:
  1308. '   Dim MyDataWrapper as VBOFDataWrapper
  1309. '   Dim MyCollection as VBOFCollection
  1310. '   Set MyDataWrapper = _
  1311. '       ObjectManager.NewVBOFDataWrapper ( _
  1312. '           Collection:=MyCollection)
  1313. ' or
  1314. '   Set MyDataWrapper = _
  1315. '       ObjectManager.NewVBOFDataWrapper ( _
  1316. '           Collection:=MyCollection, _
  1317. '           DataControl:=MyDataControl)
  1318.  
  1319.     Dim tempNewDataWrapper As New VBOFDataWrapper
  1320.     
  1321.     Set tempNewDataWrapper.ObjectManager = Me
  1322.     
  1323. ' bullet-proofing
  1324. '    If IsMissing(Collection) Then
  1325. '        pvtErrorMessage TypeName(Me) & " cannot process the '.NewVBOFDataWrapper' method because the 'Collection:=' parameter is missing."
  1326. '        Set NewVBOFDataWrapper = Nothing
  1327. '        Exit Function
  1328. '    End If
  1329.  
  1330. ' initialize the Collection
  1331.     If Not IsMissing(Collection) Then
  1332.         If Not Collection Is Nothing Then
  1333.             Set tempNewDataWrapper.Collection = _
  1334.                 Collection
  1335.         End If
  1336.     End If
  1337.     
  1338.     If Not IsMissing(DataControl) Then
  1339.         If Not DataControl Is Nothing Then
  1340.             Set tempNewDataWrapper.DataControl = _
  1341.                 DataControl
  1342.         End If
  1343.     End If
  1344.     
  1345. ' have the new wrapper bind itself to the DataControl
  1346.     If Not tempNewDataWrapper.DataControl Is Nothing Then
  1347.         If Not tempNewDataWrapper.Collection Is Nothing Then
  1348.             tempNewDataWrapper.Rebind _
  1349.                 Collection:=Collection, _
  1350.                 DataControl:=DataControl
  1351.         End If
  1352.     End If
  1353.     
  1354. ' generate a unique ObjectID for the new VBOFListBoxWrapper
  1355.     pvtVBOFCollectionID = _
  1356.         pvtVBOFCollectionID + 1
  1357.     tempNewDataWrapper.ObjectID = _
  1358.         pvtVBOFCollectionID
  1359.     
  1360. ' register the wrapper for future automatic
  1361. '   deletion as the Form terminates (through
  1362. '   TerminateForm)
  1363. '    pvtRegisterWrapperUnderForm _
  1364.         Form:=Form, _
  1365.         Wrapper:=tempNewDataWrapper
  1366.     
  1367.     Set NewVBOFDataWrapper = _
  1368.         tempNewDataWrapper
  1369. End Function
  1370.  
  1371. Public Property Get pvtObjectWasUnique() As Boolean
  1372. Attribute pvtObjectWasUnique.VB_Description = "Private"
  1373.     pvtObjectWasUnique = pvtLastAddedObjectWasUnique
  1374. End Property
  1375.  
  1376. Public Function pvtParentsOfObject( _
  1377.     Optional Object As Variant) As Collection
  1378. ' Returns a Collection of VBOFCollections which
  1379. '   are Parents of Object.
  1380. ' Note: knowledge of an Object's parents is not
  1381. '   considered good object-oriented technique
  1382.  
  1383.     Dim tempVBOFCollection As VBOFCollection
  1384.     Dim tempCollection As New Collection
  1385.     Dim I As Long
  1386.     
  1387. ' process each VBOFCollection
  1388.     I = 1
  1389.     For Each tempVBOFCollection In pvtSystemCollections
  1390.         
  1391. ' process each object therein
  1392.         If pvtObjectIndexInCollection( _
  1393.             Object:=Object, _
  1394.             Collection:=tempVBOFCollection) > 0 _
  1395.         Then
  1396.             tempCollection.Add _
  1397.                 Item:=tempVBOFCollection, _
  1398.                 Key:=CStr(I)
  1399.                 
  1400.             I = I + 1
  1401.         End If
  1402.     
  1403.     Next tempVBOFCollection
  1404.  
  1405.     Set pvtParentsOfObject = tempCollection
  1406. End Function
  1407.  
  1408. Private Function pvtObjectIndexInCollection( _
  1409.     Optional Object As Variant, _
  1410.     Optional Collection As Variant) As Long
  1411. ' Returns the index of the Object within the
  1412. '   Collection
  1413.     
  1414.     Dim tempObject As Object
  1415.     Dim I As Long
  1416.     
  1417. ' check each of the Objects defined to the
  1418. '   Collection
  1419.     I = 0
  1420.     For I = 1 To Collection.Count
  1421.         Set tempObject = Collection.Item(I)
  1422.  
  1423. ' return the Collection's index position
  1424.         If TypeName(tempObject) = TypeName(Object) Then
  1425.             If tempObject.ObjectID = Object.ObjectID Then
  1426.                 pvtObjectIndexInCollection = I
  1427.                 Exit Function
  1428.             End If
  1429.         End If
  1430.     Next I
  1431.  
  1432.     pvtObjectIndexInCollection = -1
  1433. End Function
  1434.  
  1435. Private Function pvtObjectParent( _
  1436.     Optional Object As Variant) As VBOFCollection
  1437. ' Returns the first VBOFCollection found
  1438. '   to contain Object
  1439.  
  1440.     Dim tempVBOFCollection As VBOFCollection
  1441.     Dim tempObject As Object
  1442.     
  1443. ' process each VBOFCollection
  1444.     For Each tempVBOFCollection In pvtSystemCollections
  1445.         
  1446. ' process each object therein
  1447.         If pvtObjectIndexInCollection( _
  1448.             Object:=Object, _
  1449.             Collection:=tempVBOFCollection) > 0 _
  1450.         Then
  1451.             Set pvtObjectParent = tempVBOFCollection
  1452.             Exit Function
  1453.         End If
  1454.     Next tempVBOFCollection
  1455.     
  1456. ' didn't find an Parent
  1457.     Set pvtObjectParent = Nothing
  1458. End Function
  1459.  
  1460. Private Function pvtODBCPassThrough(ODBCPassThrough As Boolean) As Long
  1461.  
  1462.     If ODBCPassThrough Then
  1463.         pvtODBCPassThrough = dbSQLPassThrough
  1464.     Else
  1465.         pvtODBCPassThrough = 0
  1466.     End If
  1467. End Function
  1468.  
  1469. Public Function RegisterForObjectEvent( _
  1470.     Optional TriggerObject As Variant, _
  1471.     Optional TriggerObjectType As Variant, _
  1472.     Optional TriggerEvent As Variant, _
  1473.     Optional RegisterObject As Variant, _
  1474.     Optional RegisterType As Variant) As Boolean
  1475. ' Pass-through to the EventManager
  1476.  
  1477. #If NoEventMgr = False Then
  1478.     RegisterForObjectEvent = _
  1479.         pvtVBOFEventManager.RegisterForObjectEvent( _
  1480.             TriggerObject:=TriggerObject, _
  1481.             TriggerObjectType:=TriggerObjectType, _
  1482.             TriggerEvent:=TriggerEvent, _
  1483.             RegisterObject:=RegisterObject, _
  1484.             RegisterType:=RegisterType)
  1485. #Else
  1486.     If Verbose Then
  1487.         DisplayErrorMessage TypeName(Me) & " (Warning) the .RegisterForObjectEvent method has been executed, but the conditional compilation parameter 'NoEventMgr = -1' has been specified.  No Event code is generated unless 'NoEventMgr = 0' or 'NoEventMgr' is missing from the conditional compilation string altogether."
  1488.     End If
  1489. #End If
  1490.  
  1491.     RegisterForObjectEvent = True
  1492. End Function
  1493.  
  1494. Public Function RegisterForCollectionEvent( _
  1495.     Optional Collection As Variant, _
  1496.     Optional RegisterObject As Variant, _
  1497.     Optional TriggerEvent As Variant) As Boolean
  1498. ' Pass-through to the EventManager
  1499.  
  1500. #If NoEventMgr = False Then
  1501.     RegisterForCollectionEvent = _
  1502.         pvtVBOFEventManager.RegisterForCollectionEvent( _
  1503.             Collection:=Collection, _
  1504.             TriggerEvent:=TriggerEvent, _
  1505.             RegisterObject:=RegisterObject)
  1506. #Else
  1507.     If Verbose Then
  1508.         DisplayErrorMessage TypeName(Me) & " (Warning) the .RegisterForCollectionEvent method has been executed, but the conditional compilation parameter 'NoEventMgr = -1' has been specified.  No Event code is generated unless 'NoEventMgr = 0' or 'NoEventMgr' is missing from the conditional compilation string altogether."
  1509.     End If
  1510. #End If
  1511.  
  1512.     RegisterForCollectionEvent = True
  1513. End Function
  1514.  
  1515.  
  1516. Public Function RemoveCollection( _
  1517.     Optional Collection As Variant, _
  1518.     Optional NoDelete As Variant, _
  1519.     Optional CleanUpMode As Variant) As Boolean
  1520. ' Remove the Collection and its contents
  1521. '
  1522. ' Note: refer to the value of CleanUpMode to
  1523. '   determine whether or not the automatic object
  1524. '   containment links between containing objects and
  1525. '   contained objects will be severed
  1526.     
  1527.     On Local Error Resume Next
  1528.         
  1529.     Collection.pvtCloseRecordSet
  1530.         
  1531.     EmptyCollection _
  1532.         Collection:=Collection, _
  1533.         NoDelete:=NoDelete, _
  1534.         CleanUpMode:=CleanUpMode
  1535.         
  1536.     UnRegisterForAllEvents _
  1537.         RegisterObject:=Collection, _
  1538.         CleanUpMode:=CleanUpMode
  1539.  
  1540.     Set Collection = Nothing
  1541.     
  1542.     RemoveCollection = True
  1543. End Function
  1544.  
  1545.  
  1546. Public Function RemoveWrapper( _
  1547.     ParamArray WrapperCollection())
  1548. ' Removes Wrapper(s) in an orderly manner.
  1549. '
  1550. ' Note: See also method "Form_QueryUnload"
  1551.  
  1552.     Dim I As Long
  1553.  
  1554.     On Local Error Resume Next
  1555.     
  1556.     For I = 0 To UBound(WrapperCollection)
  1557.         If InStr(TypeName(WrapperCollection(I)), "Wrapper") > 0 Then
  1558.             WrapperCollection(I).Unbind
  1559.             
  1560.             Me.TerminateObject _
  1561.                WrapperCollection(I)
  1562.         End If
  1563.         
  1564.         Set WrapperCollection(I) = Nothing
  1565.     Next I
  1566. End Function
  1567.  
  1568.  
  1569. Public Function SystemObject( _
  1570.     Optional TypeName As Variant, _
  1571.     Optional ObjectID As Variant) As Variant
  1572. ' Returns an Object from the pvtSystemObjects
  1573. '   collection whose TypeName matches TypeName
  1574. '   and whose ObjectID matches ObjectID
  1575. ' Note: in most cases, the results of this method
  1576. '   and the use thereof is not considered good
  1577. '   object-oriented behavior
  1578.  
  1579.     Dim tempObject As Variant
  1580.  
  1581.     On Local Error Resume Next
  1582.  
  1583. ' bullet-proofing
  1584.     If IsMissing(TypeName) _
  1585.     Or IsMissing(ObjectID) Then
  1586.         pvtErrorMessage TypeName(Me) & " cannot process the '.SystemObject' method because either the 'TypeName:=' or 'ObjectID:=' parameter is missing."
  1587.         Set SystemObject = Nothing
  1588.         Exit Function
  1589.     End If
  1590.     
  1591. ' find the desired object and return ir
  1592.     For Each tempObject In pvtSystemObjects
  1593.         If TypeName(tempObject) = TypeName Then
  1594.             If tempObject.ObjectID = ObjectID Then
  1595.                 Set SystemObject = tempObject
  1596.                 Exit Function
  1597.             End If
  1598.         End If
  1599.     
  1600.     Next tempObject
  1601.     
  1602.     Set SystemObject = Nothing
  1603. End Function
  1604.  
  1605. Public Property Get SystemObjects() As Collection
  1606. Attribute SystemObjects.VB_Description = "Private"
  1607. ' Returns a Collection (that's the VB4 Collection
  1608. '   object, not the VBOFCollection object)
  1609. '   which contains a reference to each object
  1610. '   currently being managed by VBOFObjectManager
  1611.     
  1612.     Set SystemObjects = pvtSystemObjects
  1613. End Property
  1614.  
  1615. Public Property Get SystemCollections() As Collection
  1616. Attribute SystemCollections.VB_Description = "Private"
  1617. ' Returns a Collection (that's the VB4 Collection
  1618. '   object, not the VBOFCollection object)
  1619. '   which contains a reference to each
  1620. '   VBOFCollection currently being managed by
  1621. '   VBOFObjectManager
  1622.  
  1623.     Set SystemCollections = pvtSystemCollections
  1624. End Property
  1625.  
  1626. Private Function pvtIsExactlyTheSameObject( _
  1627.     Optional Object1 As Variant, _
  1628.     Optional Object2 As Variant) As Boolean
  1629. ' Determines whether two objects are exactly the
  1630. '   same.
  1631. ' Note: this is a kind of kludge, but necessary
  1632. '   because VB doesn't return pointers to the objects
  1633.  
  1634.     Dim tempObjectID As Long
  1635.     
  1636. ' test by changing one, then checking the other
  1637.     tempObjectID = Object1.ObjectID
  1638.     Object1.ObjectID = -1
  1639.     If Object2.ObjectID = -1 Then
  1640.         pvtIsExactlyTheSameObject = True
  1641.     Else
  1642.         pvtIsExactlyTheSameObject = False
  1643.     End If
  1644.  
  1645. ' reinstate the previous value
  1646.     Object1.ObjectID = tempObjectID
  1647. End Function
  1648.  
  1649. Public Function RemoveObject( _
  1650.     Optional Object As Variant, _
  1651.     Optional Parent As Variant, _
  1652.     Optional Collection As Variant, _
  1653.     Optional NoDelete As Variant, _
  1654.     Optional CleanUpMode As Variant) As Boolean
  1655. ' Remove the Object from the specified Parent.
  1656. '   Delete the Object if its ParentCount = 0
  1657. ' Note: if a Table is supporting the Collection
  1658. '   then the VBOF automatic containment link to
  1659. '   the contained object (Collection.Parent) is also
  1660. '   severed (unless CleanUpMode:=True)
  1661.     
  1662.     Dim tempIndex As Long
  1663.     Dim tempParent As VBOFCollection
  1664.     Dim tempNoDelete As Boolean
  1665.     Dim tempCleanUpMode As Boolean
  1666.     
  1667.     On Local Error Resume Next
  1668.     
  1669. ' bullet-proofing
  1670.     If IsMissing(Object) And IsMissing(Parent) And IsMissing(Collection) Then
  1671.         pvtErrorMessage TypeName(Me) & " cannot process the '.RemoveObject' method for this object because either the 'Object:=', 'Collection:=' or the 'Parent:=' parameter is missing"
  1672.         RemoveObject = False
  1673.         Exit Function
  1674.     End If
  1675.     If Object.ObjectID < 0 Then
  1676.         RemoveObject = False
  1677.         Exit Function
  1678.     End If
  1679.     
  1680.     If IsMissing(NoDelete) Then
  1681.         tempNoDelete = False
  1682.     Else
  1683.         tempNoDelete = NoDelete
  1684.     End If
  1685.     
  1686.     If IsMissing(CleanUpMode) Then
  1687.         tempCleanUpMode = False
  1688.     Else
  1689.         tempCleanUpMode = CleanUpMode
  1690.     End If
  1691.  
  1692. ' if the Parent:= is missing, find the first Parent
  1693. '   Note: herein, a Parent is an VBOFCollection
  1694.     If Not IsMissing(Parent) Then
  1695.         Set tempParent = Parent
  1696.     ElseIf Not IsMissing(Collection) Then
  1697.         Set tempParent = Collection
  1698.     Else
  1699.         Set tempParent = _
  1700.             pvtObjectParent(Object)
  1701.     End If
  1702.     
  1703. ' remove event registrations
  1704. #If NoEventMgr = False Then
  1705.     UnRegisterForAllEvents _
  1706.         RegisterObject:=Object, _
  1707.         CleanUpMode:=CleanUpMode
  1708. #End If
  1709.  
  1710. ' schedule orphans to be deleted
  1711.     If tempParent Is Nothing Then
  1712.         Object.ObjectParentCount = 0
  1713.     End If
  1714.     
  1715. ' if there's only 1 Parent (or less)
  1716.     If pvtParentsOfObject(Object).Count <= 1 Then
  1717.     
  1718. ' remove the Object from the specified Parent,
  1719. '   and delete it according to NoDelete
  1720.         If Not tempParent Is Nothing Then
  1721.             tempParent.Remove _
  1722.                 Item:=Object, _
  1723.                 NoDelete:=tempNoDelete, _
  1724.                 CleanUpMode:=CleanUpMode
  1725.         End If
  1726.         
  1727. #If NoDebugMode = False Then
  1728.         If DebugMode Then
  1729.             DisplayDebugMessage _
  1730.                 TypeName(Me) & " 'RemoveObject' has removed the ObjectType=" & _
  1731.                 TypeName(Object) & _
  1732.                 ", ObjectID=" & _
  1733.                 Object.ObjectID
  1734.         End If
  1735. #End If
  1736.         
  1737. ' free the Object
  1738.         pvtFreeObject _
  1739.             Object:=Object
  1740.         
  1741.         RemoveObject = True
  1742.         Exit Function
  1743.     
  1744. ' remove the Object from the specified Parent,
  1745. '   but don't delete it
  1746.     Else
  1747.         Parent.Remove _
  1748.             Item:=Object, _
  1749.             NoDelete:=True, _
  1750.             CleanUpMode:=CleanUpMode
  1751.  
  1752. ' drop Object's ParentCount by 1
  1753.         Object.ObjectParentCount = _
  1754.             Object.ObjectParentCount - 1
  1755.         
  1756. #If NoDebugMode = False Then
  1757.         If DebugMode Then
  1758.             DisplayDebugMessage _
  1759.                 TypeName(Me) & " 'RemoveObject' has decremented the ObjectParentCount to " & Object.ObjectParentCount & " for ObjectType=" & _
  1760.                 TypeName(Object) & _
  1761.                 ", ObjectID=" & _
  1762.                 Object.ObjectID
  1763.         End If
  1764. #End If
  1765.         
  1766.         RemoveObject = True
  1767.         Exit Function
  1768.     End If
  1769. End Function
  1770.  
  1771. Private Function pvtErrorMessage( _
  1772.     Optional ErrorMessage As Variant) As Long
  1773.     pvtErrorMessage = _
  1774.         DisplayErrorMessage(ErrorMessage)
  1775. End Function
  1776.  
  1777.  
  1778. Private Function pvtObjectIndexInSystemObjects( _
  1779.     Optional Object As Variant) As Long
  1780. ' Return the Index of Object in the collection
  1781. '   of system objects
  1782.     
  1783.     Dim tempObject As Object
  1784.     Dim I As Long
  1785.     
  1786.     On Local Error Resume Next
  1787.     
  1788. ' quick-check to see if the object exists
  1789.     Set tempObject = _
  1790.         pvtSystemObjects(TypeName(Object) & " " & _
  1791.         CStr(Object.ObjectID))
  1792.     If Err = 5 Then
  1793.         pvtObjectIndexInSystemObjects = -1
  1794.         Exit Function
  1795.     End If
  1796.     
  1797. ' the object likely exists in the SystemObjects.
  1798. '   find its Index.
  1799.  
  1800. ' check each of the objects known at this time
  1801.     I = 0
  1802.     For Each tempObject In pvtSystemObjects
  1803.         I = I + 1
  1804.  
  1805. ' return the collection's index position
  1806.         If TypeName(tempObject) = TypeName(Object) Then
  1807.             If tempObject.ObjectID = Object.ObjectID Then
  1808.                 pvtObjectIndexInSystemObjects = I
  1809.                 Exit Function
  1810.             End If
  1811.         End If
  1812.     Next tempObject
  1813.  
  1814.  ' return "not found"
  1815.     pvtObjectIndexInSystemObjects = -1
  1816.     Exit Function
  1817. End Function
  1818.  
  1819.  
  1820. Public Function pvtAddUniqueObject(Optional Object As Variant, Optional Parent As Variant) As Variant
  1821. Attribute pvtAddUniqueObject.VB_Description = "(Private) Ensures no duplicate instances of a given object exist"
  1822. ' Return a system-wide unique object which is the
  1823. '   Item, or an already existing, functionally
  1824. '   equivalent of the Item
  1825. ' Note: this method, while public, is designed to be
  1826. '   invoked only by the .Add method of an instance
  1827. '   of VBOFCollection.  Any other use must make
  1828. '   allowances for Object to have been freed and
  1829. '   replaced by an equivalent object which was
  1830. '   found to have already existed under the control
  1831. '   of VBOFObjectManager
  1832.     
  1833.     Dim tempObject As Object
  1834.     Dim tempIndex As Long
  1835.     
  1836.     On Local Error Resume Next
  1837.     pvtLastAddedObjectWasUnique = False
  1838.     
  1839. ' bullet-proofing
  1840.     If IsMissing(Object) Then
  1841.         pvtErrorMessage TypeName(Me) & " cannot process the '.pvtAddUniqueObject' method for this object because the 'Object:=' parameter is missing"
  1842.         pvtAddUniqueObject = False
  1843.         Exit Function
  1844.     End If
  1845.     
  1846. ' initialize all objects that pass through here,
  1847. '   in support of VBOF services
  1848.     Set Object.ObjectManager = _
  1849.         Me
  1850.  
  1851. ' check each of the objects known at this time
  1852.     tempIndex = _
  1853.         pvtObjectIndexInSystemObjects _
  1854.             (Object:=Object)
  1855.  
  1856. ' if found, return the located object
  1857.     If tempIndex > 0 Then
  1858.         Set tempObject = _
  1859.             pvtSystemObjects.Item _
  1860.                 (tempIndex)
  1861.         
  1862. ' if these are exactly the same object
  1863.         If pvtIsExactlyTheSameObject( _
  1864.             Object1:=Object, _
  1865.             Object2:=tempObject) _
  1866.         Then
  1867.  
  1868. ' increase the ParentCount of the previously
  1869. '   existing object
  1870.             Object.ObjectParentCount = _
  1871.                 Object.ObjectParentCount + 1
  1872.  
  1873. #If NoDebugMode = False Then
  1874.             If DebugMode Then
  1875.                 DisplayDebugMessage _
  1876.                     TypeName(Me) & " 'Add Object' attempt found exact same (already existing) Object.  ObjectType=" & _
  1877.                     TypeName(Object) & _
  1878.                     ", ObjectID=" & _
  1879.                     Object.ObjectID
  1880.             End If
  1881. #End If
  1882.             
  1883.         Else
  1884. ' else, free the Object (the parameter)
  1885.             Object.ObjectID = -1
  1886.             Set Object = Nothing
  1887.         End If
  1888.         
  1889. ' return the located object
  1890.         Set pvtAddUniqueObject = _
  1891.             pvtSystemObjects.Item _
  1892.                 (tempIndex)
  1893.  
  1894. #If NoDebugMode = False Then
  1895.         If DebugMode Then
  1896.             DisplayDebugMessage _
  1897.                 TypeName(Me) & " 'Add Object' attempt found an existing Object.  ObjectType=" & _
  1898.                 TypeName(Object) & _
  1899.                 ", ObjectID=" & _
  1900.                 Object.ObjectID
  1901.         End If
  1902. #End If
  1903.  
  1904.         GoTo pvtAddUniqueObject_Exit
  1905.     End If
  1906.     
  1907. ' else, the object is unique
  1908. '   add the object to the collection of system objects
  1909.     pvtSystemObjects.Add _
  1910.         Item:=Object, _
  1911.         Key:=TypeName(Object) & " " & CStr(Object.ObjectID)
  1912.         
  1913. ' mark the object as "Added"
  1914.     Object.ObjectAdded = True
  1915.  
  1916. ' trigger the "Instantiated" event for the new object
  1917. #If NoEventMgr = False Then
  1918.     TriggerObjectEvent _
  1919.         Event:="Instantiated", _
  1920.         Object:=Object
  1921. #End If
  1922.  
  1923. #If NoDebugMode = False Then
  1924.     If DebugMode Then
  1925.         DisplayDebugMessage _
  1926.             TypeName(Me) & " 'Add Object' attempt did not find any existing Object.  The Object was added, ObjectType=" & _
  1927.             TypeName(Object) & _
  1928.             ", ObjectID=" & _
  1929.             Object.ObjectID
  1930.     End If
  1931. #End If
  1932.  
  1933. ' initialize the new object in support of
  1934. '   VBOF services
  1935.     InitializeObject _
  1936.         Object:=Object
  1937.  
  1938. ' return the original object
  1939.     Set pvtAddUniqueObject = Object
  1940.     pvtLastAddedObjectWasUnique = True
  1941.  
  1942. pvtAddUniqueObject_Exit:
  1943.     Set tempObject = Nothing
  1944. End Function
  1945.  
  1946. Public Function DisplayErrorMessage( _
  1947.     Optional ErrorMessage As Variant) As Long
  1948.  
  1949.     Dim RC As Long
  1950.  
  1951.     If Err <> 0 Then
  1952.         RC = MsgBox( _
  1953.             ErrorMessage & vbCrLf & "Err=" & Err & ", Msg=" & Error(Err) & _
  1954.             vbCrLf & "Version=" & Version & ", Date=" & VersionDate, _
  1955.             vbOK + vbExclamation, _
  1956.             TypeName(Me) & " Run-Time Message")
  1957.     Else
  1958.         RC = MsgBox( _
  1959.             ErrorMessage & _
  1960.             vbCrLf & "Version=" & Version, _
  1961.             vbOK + vbExclamation, _
  1962.             TypeName(Me) & " Run-Time Message")
  1963.     End If
  1964.     
  1965.     Err = 0
  1966.     DisplayErrorMessage = RC
  1967. End Function
  1968.  
  1969.  
  1970. Public Property Get ObjectManager() As VBOFObjectManager
  1971. Attribute ObjectManager.VB_Description = "Private"
  1972.     Set ObjectManager = Me
  1973. End Property
  1974.  
  1975.  
  1976.  
  1977.  
  1978. Public Property Get ObjectID() As Long
  1979. Attribute ObjectID.VB_Description = "Private"
  1980.     ObjectID = -1
  1981. End Property
  1982.  
  1983.  
  1984.  
  1985. Public Function NewVBOFCollection( _
  1986.     Optional Database As Variant, _
  1987.     Optional Parent As Variant, _
  1988.     Optional Owner As Variant) As VBOFCollection
  1989. '  Return a new, properly instantiated
  1990. '   VBOFCollection object
  1991.  
  1992.     Dim tempVBOFCollection As New VBOFCollection
  1993.     
  1994.     On Local Error Resume Next
  1995.     
  1996. ' generate a unique ObjectID for the new VBOFCollection
  1997.     pvtVBOFCollectionID = pvtVBOFCollectionID + 1
  1998.     
  1999. ' initialize
  2000.     Set tempVBOFCollection.ObjectManager = Me
  2001.     With tempVBOFCollection
  2002.         .ObjectID = pvtVBOFCollectionID
  2003.         .AutoDeleteOrphans = Me.AutoDeleteOrphans
  2004.         .SwapIfEqualSortOrder = Me.SwapIfEqualSortOrder
  2005.     End With
  2006.     
  2007. ' set any known parameters
  2008.     If Not IsMissing(Database) Then
  2009.         Set pvtDatabase = Database
  2010.     End If
  2011.     If Not IsMissing(Owner) Then
  2012.         Set tempVBOFCollection.Parent = Owner
  2013.     End If
  2014.     If Not IsMissing(Parent) Then
  2015.         Set tempVBOFCollection.Parent = Parent
  2016.     End If
  2017.  
  2018. ' pass-along any known database parms
  2019.     tempVBOFCollection.SetDatabaseParameters _
  2020.         ODBCPassThrough:=ODBCPassThrough, _
  2021.         ANSISQL:=ANSISQL, _
  2022.         Database:=pvtDatabase
  2023.  
  2024. ' add the new VBOFCollection to the
  2025. '   system-wide collection of
  2026. '   VBOFCollections, for object management
  2027. '   purposes
  2028.     pvtSystemCollections.Add _
  2029.         Item:=tempVBOFCollection
  2030.  
  2031. #If NoDebugMode = False Then
  2032.     If DebugMode Then
  2033.         DisplayDebugMessage _
  2034.             TypeName(Me) & " 'NewVBOFCollection' completed, new ObjectID=" & _
  2035.             tempVBOFCollection.ObjectID
  2036.     End If
  2037. #End If
  2038.  
  2039.     Set NewVBOFCollection = tempVBOFCollection
  2040. End Function
  2041.  
  2042.  
  2043. Public Sub Form_QueryUnload( _
  2044.     Form As Variant, _
  2045.     ParamArray WrapperCollection())
  2046. ' Cleans-up while a Form is being Unloaded
  2047. '
  2048. ' Programming Example:
  2049. '   Private Sub Form_QueryUnload(...)
  2050. '       If Not ObjectManager Is Nothing Then
  2051. '           ObjectManager.Form_QueryUnload _
  2052. '               Me, _
  2053. '               MyListBoxWrapper, _
  2054. '               MyListBoxOtherWrapper, _
  2055. '               MyDBGridWrapper, _
  2056. '               MyDBGridOtherWrapper, _
  2057. '               . . .
  2058. '       End If
  2059.     
  2060.     Dim tempWrapper As Variant
  2061.     Dim tempWrapperArray(1 To 1) As Variant
  2062.     
  2063.     On Local Error Resume Next
  2064.     
  2065. ' remove event registrations
  2066. #If NoEventMgr = False Then
  2067.     UnRegisterForAllEvents _
  2068.         RegisterObject:=Form, _
  2069.         CleanUpMode:=False
  2070. #End If
  2071.  
  2072. ' clear the registered Wrappers for the Form
  2073.     For Each tempWrapper In pvtSystemWrappers
  2074.         If TypeName(tempWrapper.Form) = _
  2075.             TypeName(Form) _
  2076.         Then
  2077.             Set tempWrapperArray(1) = _
  2078.                 tempWrapper
  2079.             
  2080.             Me.RemoveWrapper _
  2081.                 tempWrapperArray()
  2082.     
  2083. ' unregister the Wrapper from the Form
  2084.             pvtUnRegisterWrapperUnderForm _
  2085.                 Form:=Form, _
  2086.                 Wrapper:=tempWrapper
  2087.         End If
  2088.                 
  2089.     Next tempWrapper
  2090.  
  2091. ' clear the requested wrappers
  2092.     Me.RemoveWrapper _
  2093.         WrapperCollection()
  2094.  
  2095. End Sub
  2096.  
  2097. Public Function TerminateForm(Form As Variant, ParamArray WrapperCollection())
  2098. Attribute TerminateForm.VB_Description = "Private"
  2099. ' Cleans-up while a Form is being Unloaded.
  2100. '
  2101. ' Note:  This is the equivalent of the method
  2102. '   "Form_QueryUnload" but this method's name
  2103. '   might be easier for the programmer to remember,
  2104. '   given that there is a method named
  2105. '   "TerminateObject", as well, used for
  2106. '   terminating objects
  2107. '
  2108. ' Programming Example:
  2109. '   Private Sub Form_QueryUnload(...)
  2110. '       If Not ObjectManager Is Nothing Then
  2111. '           ObjectManager.TerminateForm _
  2112. '               Me, _
  2113. '               MyListBoxWrapper, _
  2114. '               MyListBoxOtherWrapper, _
  2115. '               MyDBGridWrapper, _
  2116. '               MyDBGridOtherWrapper, _
  2117. '               . . .
  2118. '       End If
  2119.  
  2120.     Me.Form_QueryUnload _
  2121.         Form, _
  2122.         WrapperCollection()
  2123.  
  2124. End Function
  2125.  
  2126.  
  2127. Public Function TerminateObject( _
  2128.     Object As Variant) As Boolean
  2129. ' Cleans-up while an object is being terminated.
  2130. '
  2131. ' Programming Example:
  2132. '   Private Sub Class_Terminate()
  2133. '       If Not ObjectManager Is Nothing Then
  2134. '           ObjectManager.TerminateObject _
  2135. '               Object:=Me
  2136. '       End If
  2137.  
  2138.     Me.RemoveObject _
  2139.         Object:=Object, _
  2140.         NoDelete:=True, _
  2141.         CleanUpMode:=False
  2142.  
  2143. End Function
  2144.  
  2145. Public Function TriggerObjectEvent( _
  2146.     Optional Event As Variant, _
  2147.     Optional Object As Variant, _
  2148.     Optional Verbose As Variant) As Boolean
  2149. ' Pass-through to the EventManager
  2150.  
  2151. #If NoEventMgr = False Then
  2152.     TriggerObjectEvent = _
  2153.         pvtVBOFEventManager.TriggerObjectEvent( _
  2154.             Event:=Event, _
  2155.             Object:=Object, _
  2156.             Verbose:=Verbose)
  2157. #Else
  2158.     If Verbose Then
  2159.         DisplayErrorMessage TypeName(Me) & " (Warning) the .TriggerObjectEvent method has been executed, but the conditional compilation parameter 'NoEventMgr = -1' has been specified.  No Event code is generated unless 'NoEventMgr = 0' or 'NoEventMgr' is missing from the conditional compilation string altogether."
  2160.     End If
  2161. #End If
  2162.             
  2163.     TriggerObjectEvent = True
  2164. End Function
  2165.  
  2166. Public Function TriggerCollectionEvent( _
  2167.     Optional Event As Variant, _
  2168.     Optional Object As Variant, _
  2169.     Optional Collection As Variant, _
  2170.     Optional Verbose As Variant, _
  2171.     Optional NoDelete As Variant) As Boolean
  2172. ' Pass-through to the EventManager
  2173.  
  2174. #If NoEventMgr = False Then
  2175.     pvtVBOFEventManager.TriggerCollectionEvent _
  2176.         Event:=Event, _
  2177.         Object:=Object, _
  2178.         Collection:=Collection, _
  2179.         Verbose:=Verbose, _
  2180.         NoDelete:=NoDelete
  2181. #Else
  2182.     If Verbose Then
  2183.         DisplayErrorMessage TypeName(Me) & " (Warning) the .TriggerCollectionEvent method has been executed, but the conditional compilation parameter 'NoEventMgr = -1' has been specified.  No Event code is generated unless 'NoEventMgr = 0' or 'NoEventMgr' is missing from the conditional compilation string altogether."
  2184.     End If
  2185. #End If
  2186.             
  2187.     TriggerCollectionEvent = True
  2188. End Function
  2189.  
  2190.  
  2191. Public Function UnRegisterForAllEvents( _
  2192.     Optional RegisterObject As Variant, _
  2193.     Optional CleanUpMode As Variant) As Boolean
  2194. ' Unregisters the UnregisterObject from all
  2195. '   events
  2196. '   (a wrapper method for
  2197. '       Me.UnRegisterForCollectionEvent and
  2198. '       Me.UnRegisterForObjectEvent
  2199.  
  2200.     Dim tempCleanUpMode As Boolean
  2201.  
  2202.     If IsMissing(CleanUpMode) Then
  2203.         tempCleanUpMode = False
  2204.     Else
  2205.         tempCleanUpMode = CleanUpMode
  2206.     End If
  2207.  
  2208. #If NoEventMgr = False Then
  2209.     Me.UnRegisterForCollectionEvent _
  2210.         RegisterObject:=RegisterObject, _
  2211.         CleanUpMode:=tempCleanUpMode
  2212.  
  2213.     Me.UnRegisterForObjectEvent _
  2214.         RegisterObject:=RegisterObject, _
  2215.         CleanUpMode:=tempCleanUpMode
  2216. #End If
  2217. End Function
  2218.  
  2219. Public Function UnRegisterForObjectEvent( _
  2220.     Optional RegisterObject As Variant, _
  2221.     Optional CleanUpMode As Variant) As Boolean
  2222. ' UnRegister the Object for Events
  2223.  
  2224. ' don't bother doing this during "CleanUpMode"
  2225. '   because ObjectManager is being killed, anyway
  2226.     If Not IsMissing(CleanUpMode) Then
  2227.         If CleanUpMode Then
  2228.             UnRegisterForObjectEvent = True
  2229.             Exit Function
  2230.         End If
  2231.     End If
  2232.  
  2233. #If NoEventMgr = False Then
  2234.     If Not pvtVBOFEventManager Is Nothing Then
  2235.         pvtVBOFEventManager.UnRegisterForObjectEvent _
  2236.             RegisterObject:=RegisterObject
  2237.     End If
  2238. #Else
  2239.     If Verbose Then
  2240.         DisplayErrorMessage TypeName(Me) & " (Warning) the .UnRegisterForObjectEvent method has been executed, but the conditional compilation parameter 'NoEventMgr = -1' has been specified.  No Event code is generated unless 'NoEventMgr = 0' or 'NoEventMgr' is missing from the conditional compilation string altogether."
  2241.     End If
  2242. #End If
  2243.  
  2244.     UnRegisterForObjectEvent = True
  2245. End Function
  2246.  
  2247.  
  2248. Public Property Get Version() As String
  2249. Attribute Version.VB_Description = "Returns the current version of VBOF"
  2250.     Version = "1.1"
  2251. End Property
  2252.  
  2253. Public Property Get VersionDate() As String
  2254. Attribute VersionDate.VB_Description = "Returns the current version date of VBOF"
  2255.     VersionDate = "1996-03-03"
  2256. End Property
  2257.  
  2258.  
  2259. Private Sub Class_Initialize()
  2260.  
  2261. #If NoEventMgr = False Then
  2262.     Set pvtVBOFEventManager = _
  2263.         New VBOFEventManager
  2264.     Set pvtVBOFEventManager.ObjectManager = _
  2265.         Me
  2266. #End If
  2267.     
  2268.     Set pvtDatabase = Nothing
  2269.     
  2270. '    pvtSynchronousCommit = False
  2271.     pvtDebugMode = False
  2272.     pvtVerbose = False
  2273.     AutoDeleteOrphans = False
  2274.     pvtLastAddedObjectWasUnique = False
  2275.     pvtVBOFCollectionID = 0
  2276.     pvtHighestObjectID = 0
  2277.     ANSISQL = False
  2278.     ODBCPassThrough = False
  2279.  
  2280. End Sub
  2281.  
  2282. Public Property Get ObjectEventManager() As Variant
  2283. Attribute ObjectEventManager.VB_Description = "Private"
  2284. ' Returns my pvtEventManager
  2285.     
  2286. #If NoEventMgr = False Then
  2287.     Set ObjectEventManager = pvtVBOFEventManager
  2288. #Else
  2289.     Set ObjectEventManager = Nothing
  2290. #End If
  2291. End Property
  2292.  
  2293. Private Function pvtFreeObject( _
  2294.     Optional Object As Variant, _
  2295.     Optional Index As Variant) As Boolean
  2296. ' Free the Object and remove it from the collection
  2297. '   of known system objects
  2298.         
  2299.     On Local Error Resume Next
  2300.         
  2301.     If Not IsMissing(Index) Then
  2302.         pvtSystemObjects.Remove Index
  2303.     Else
  2304.         pvtSystemObjects.Remove _
  2305.             pvtObjectIndexInSystemObjects(Object:=Object)
  2306.     End If
  2307.         
  2308.     Set Object = Nothing
  2309.     pvtFreeObject = True
  2310. End Function
  2311.  
  2312.  
  2313.  
  2314. Private Function pvtCommitObjects() As Boolean
  2315. ' NOT CURRENTLY SUPPORTED
  2316. '
  2317. ' Coordinates a synchronous database Commit across
  2318. '   all currently instantiated objects.
  2319. ' Returns True or False, depending on whether or not
  2320. '   the Commit was successful (False means that a
  2321. '   Rollback has been issued)
  2322. ' Note: requires use of SynchronousCommit:=True
  2323. '   in a parameter to VBOFObjectManager
  2324.  
  2325.     Dim tempVBOFCollection As VBOFCollection
  2326.     
  2327. ' bullet-proofing
  2328.     If pvtSynchronousCommit = False Then
  2329.         pvtErrorMessage TypeName(Me) & " cannot process the '.CommitObjects' method because the 'SynchronousCommit' environment does not exist.  Execute 'ObjectManager.SynchronousCommit = True'to establish the correct environment."
  2330.         pvtCommitObjects = False
  2331.         Exit Function
  2332.     End If
  2333.      
  2334. #If NoDebugMode = False Then
  2335.     If DebugMode Then
  2336.         DisplayDebugMessage _
  2337.             TypeName(Me) & " Starting 'CommitObjects' processing."
  2338.     End If
  2339. #End If
  2340.  
  2341. ' start the transaction
  2342.     pvtWorkspace.BeginTrans
  2343.     
  2344. ' process each VBOFCollection
  2345.     For Each tempVBOFCollection In pvtSystemCollections
  2346.         
  2347. ' have each commit
  2348.         If Not tempVBOFCollection.Commit Then
  2349.             pvtWorkspace.Rollback
  2350.             pvtCommitObjects = False
  2351.             Exit Function
  2352.         End If
  2353.     Next tempVBOFCollection
  2354.     
  2355. ' commit the transaction
  2356.     pvtWorkspace.CommitTrans
  2357.      
  2358. #If NoDebugMode = False Then
  2359.     If DebugMode Then
  2360.         DisplayDebugMessage _
  2361.             TypeName(Me) & " 'CommitObjects' finished successfully."
  2362.     End If
  2363. #End If
  2364.  
  2365.     pvtCommitObjects = True
  2366.     Exit Function
  2367. End Function
  2368.  
  2369. Public Property Set Database(aDatabase As Database)
  2370. Attribute Database.VB_Description = "Sets the Database property"
  2371.     Set pvtDatabase = aDatabase
  2372.      
  2373. #If NoDebugMode = False Then
  2374.     If DebugMode Then
  2375.         DisplayDebugMessage _
  2376.             TypeName(Me) & " 'Database' set to " & TypeName(aDatabase)
  2377.     End If
  2378. #End If
  2379.  
  2380. End Property
  2381.  
  2382. Public Property Get Database() As Database
  2383.     Set Database = pvtDatabase
  2384. End Property
  2385.  
  2386.  
  2387. Public Property Get Workspace() As Workspace
  2388. Attribute Workspace.VB_Description = "Maps to the Workspace property"
  2389.     Set Workspace = pvtWorkspace
  2390. End Property
  2391.  
  2392. Public Property Set Workspace(aWorkspace As Workspace)
  2393.     Set pvtWorkspace = aWorkspace
  2394. End Property
  2395.  
  2396. Public Function EmptyCollection( _
  2397.     Optional Collection As Variant, _
  2398.     Optional NoDelete As Variant, _
  2399.     Optional CleanUpMode As Variant) As Boolean
  2400. ' Empty the VBOFCollection of all its Objects.
  2401. '
  2402. ' Note: if a DataSource is supporting the Collection
  2403. '   then the VBOF automatic containment links to
  2404. '   the contained objects are also severed
  2405.     
  2406.     Dim tempIndex As Long
  2407.     Dim tempVBOFCollection As VBOFCollection
  2408.     Dim tempObject As Object
  2409.     Dim I As Long
  2410.     
  2411.     On Local Error Resume Next
  2412.     
  2413. ' bullet-proofing
  2414.     If IsMissing(Collection) Then
  2415.         pvtErrorMessage TypeName(Me) & " cannot process the '.EmptyCollection' method for this object because the 'Collection:=' parameter is missing"
  2416.         EmptyCollection = False
  2417.         Exit Function
  2418.     End If
  2419.     
  2420. ' free all of its referenced Objects
  2421.     For I = 1 To Collection.Count
  2422.         
  2423.         Set tempObject = Collection.Item(1)
  2424.         
  2425. #If NoDebugMode = False Then
  2426.         If DebugMode Then
  2427.             DisplayDebugMessage _
  2428.                 TypeName(Me) & " 'RemoveCollection' is removing the Collection.ObjectID=" & _
  2429.                 tempObject.ObjectID
  2430.         End If
  2431. #End If
  2432.  
  2433.         RemoveObject _
  2434.             Object:=tempObject, _
  2435.             Parent:=Collection, _
  2436.             NoDelete:=NoDelete, _
  2437.             CleanUpMode:=CleanUpMode
  2438.             
  2439.     Next I
  2440.     
  2441.     EmptyCollection = True
  2442. End Function
  2443.  
  2444. Public Property Let DebugMode(aBoolean As Boolean)
  2445. Attribute DebugMode.VB_Description = "Maps to the DebugMode property"
  2446.     pvtDebugMode = aBoolean
  2447.     
  2448. #If NoDebugMode = False Then
  2449.     If pvtDebugMode Then
  2450.         DisplayDebugMessage TypeName(Me) & " starting debug mode"
  2451.     End If
  2452. #Else
  2453.     If aBoolean Then
  2454.         DisplayErrorMessage TypeName(Me) & " (Warning) DebugMode has been requested, but the conditional compilation parameter 'NoDebugMode = -1' has been specified.  No debug code is generated unless 'NoDebugMode = 0' or 'NoDebug' is missing from the conditional compilation string altogether."
  2455.     End If
  2456. #End If
  2457. End Property
  2458.  
  2459. Public Property Get DebugMode() As Boolean
  2460.     DebugMode = pvtDebugMode
  2461. End Property
  2462.  
  2463.  
  2464. Public Property Get Verbose() As Boolean
  2465. Attribute Verbose.VB_Description = "Maps to the Verbose property"
  2466.     Verbose = pvtVerbose
  2467. End Property
  2468. Public Property Let Verbose(aBoolean As Boolean)
  2469.     pvtVerbose = aBoolean
  2470. End Property
  2471.  
  2472.  
  2473. Private Property Get pvtSynchronousCommit()
  2474. ' NOT CURRENTLY SUPPORTED
  2475. '
  2476. ' Return the current state of the
  2477. '   SynchronousCommit environment (True or False)
  2478.     
  2479. '    SynchronousCommit = pvtSynchronousCommit
  2480. End Property
  2481.  
  2482. Private Property Let pvtSynchronousCommit(aBoolean)
  2483. ' NOT CURRENTLY SUPPORTED
  2484. '
  2485. ' Set the SynchronousCommit environment to aBoolean
  2486.         
  2487. '#If NoDebugMode = False Then
  2488. '    If DebugMode Then
  2489. '        DisplayDebugMessage _
  2490. '            TypeName(Me) & " 'SynchronousCommit' mode has been set to " & aBoolean
  2491. '    End If
  2492. '#End If
  2493.     
  2494. '    pvtSynchronousCommit = aBoolean
  2495. End Property
  2496.  
  2497. Public Function UnRegisterForCollectionEvent( _
  2498.     Optional RegisterObject As Variant, _
  2499.     Optional CleanUpMode As Variant) As Boolean
  2500. ' UnRegister the Collection for Events
  2501.  
  2502. ' don't bother doing this during "CleanUpMode",
  2503. '   because ObjectManager is being killed, anyway
  2504.     If Not IsMissing(CleanUpMode) Then
  2505.         If CleanUpMode Then
  2506.             UnRegisterForCollectionEvent = True
  2507.             Exit Function
  2508.         End If
  2509.     End If
  2510.  
  2511. #If NoEventMgr = False Then
  2512.     If Not pvtVBOFEventManager Is Nothing Then
  2513.         pvtVBOFEventManager.UnRegisterForCollectionEvent _
  2514.             RegisterObject:=RegisterObject, _
  2515.             CleanUpMode:=CleanUpMode
  2516.     End If
  2517. #Else
  2518.     If Verbose Then
  2519.         DisplayErrorMessage TypeName(Me) & " (Warning) the .UnRegisterForCollectionEvent method has been executed, but the conditional compilation parameter 'NoEventMgr = -1' has been specified.  No Event code is generated unless 'NoEventMgr = 0' or 'NoEventMgr' is missing from the conditional compilation string altogether."
  2520.     End If
  2521. #End If
  2522.  
  2523.     UnRegisterForCollectionEvent = True
  2524. End Function
  2525.  
  2526.  
  2527.  
  2528. Public Property Get AutoDeleteOrphans() As Boolean
  2529. Attribute AutoDeleteOrphans.VB_Description = "Maps to the AutoDeleteOrphans property"
  2530.     AutoDeleteOrphans = pvtAutoDeleteOrphans
  2531. End Property
  2532.  
  2533. Public Property Let AutoDeleteOrphans(aBoolean As Boolean)
  2534.     pvtAutoDeleteOrphans = aBoolean
  2535. End Property
  2536.  
  2537.  
  2538.  
  2539.  
  2540. Private Sub Class_Terminate()
  2541. #If NoEventMgr = False Then
  2542.     Set pvtVBOFEventManager = Nothing
  2543. #End If
  2544.  
  2545.     Set pvtSystemCollections = Nothing
  2546.     Set pvtSystemObjects = Nothing
  2547. End Sub
  2548.  
  2549.  
  2550.